<?php

namespace component\element\multiimage\controller;

use core\component\ElementBase;
use core\lib\upload\UploadImage;
use core\traits\ElementView as TraitsElementView;
use core\traits\Response as TraitsResponse;
use Exception;

class Index extends ElementBase
{


    public function index(...$param)
    {
        return $this->view($param);
    }

    /**
     * 上传图片
     *
     * @return mixed
     */
    public function upload()
    {
        try {

            $path = request()->elementinfo['plugin'] == '' ? 'frame'
                : request()->elementinfo['plugin'];


            $uploadImage = new UploadImage(
                path: $path,
            );
            $res = $uploadImage->upload();
        } catch (Exception $ex) {
            return $this->error($ex->getMessage());
        }

        return $this->success($res);
    }
}
